// index.js
// 获取应用实例
const app = getApp()

Page({
  data: {
    imgUrls: [{
    url: '../imgs/2.jpg'
    }, {
    url: '../imgs/5.jpg'
    }, {
    url: '../imgs/4.jpg'
    }],
    
    indicatorDots: true,
    
    autoplay: true,
    
    interval: 5000,
    
    duration: 1000,
     
    currentIndex: 0,

    dates:'',
    
    tiems:'',

    index: 0,

    commonUse:'',

    item:''
    },
    /* 这里实现当前页面的样式 */
handleImgChange: function (e) {
  this.setData({
  currentIndex: e.detail.current
  })} ,

  //  点击周六组件确定事件  
  bindDateChange: function (e) {
     console.log(e.detail.value)
    this.setData({
      dates: e.detail.value,
      satDate:e.detail.value
    })
  },
  //点击周日组件确定事件
  bindTimeChange:function(e){
   this.setData({
    tiems:e.detail.value,
    sunTime:e.detail.value
   })
  },
  //form表单提交
  formSubmit:function(e){
   console.log('数据为：',e.detail.value);
   wx.request({
     url: 'url',
     method:'POST',
     data:e.detail.value,
     header: { 
       "Content-Type": "application/x-www-form-urlencoded" //POST方式是这个
      },
     success:function(res){//请求成功之后要做什么
     wx.showToast({
       title: '提交成功',
     })
     //重置表单
      that.setData({
        commonUse:'',
        item:''
      })
      },
      fail:function(err){//请求失败之后要做什么
        wx.showToast({
          title: '提交失败',
          massge:err
        })
      }
   })
  },
  //页面加载完成时执行
  onLoad:function(options){
    var timestamp = Date.parse(new Date());
    var date = new Date(timestamp);
    //获取年份  
    var Y =date.getFullYear();
    //获取月份  
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
    //获取当日日期 
    var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate(); 
    //给data赋值
    var that=this;
    that.setData({
      dates:Y + '-' + M+ '-' + D,
      tiems:Y + '-' + M+ '-' + D
    })
  }
})
